

package jetbrains.buildServer.server.rest.data.util;

import java.util.HashSet;
import java.util.Set;
import org.jetbrains.annotations.NotNull;

/**
 * Simple set-based duplicate checker. Please ensure that ITEM properly implements equals and hashCode!
 */
public class SetDuplicateChecker<ITEM> implements DuplicateChecker<ITEM> {
  private final Set<ITEM> mySeenItems = new HashSet<>();

  @Override
  public boolean checkDuplicateAndRemember(@NotNull ITEM item) {
    return !mySeenItems.add(item);
  }
}